
USE [arirang_klist]
GO

IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vdmProductInput]'))
DROP VIEW [dbo].[vdmProductInput]
GO
/****** Object:  View [dbo].[vdmProductInput]    Script Date: 04/04/2013 16:28:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[vdmProductInput]
AS
	SELECT a.product_id as id, COUNT(a.product_id) as num_inventory , a.agency_id, MAX(b.name)  as name
	FROM tbl_product_stock a LEFT JOIN tbl_product b ON a.product_id = b.id
	GROUP BY product_id, agency_id

GO


